<template >
  <div id="reports">
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/menu/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/menu/">数据统计</a></el-breadcrumb-item>
      <el-breadcrumb-item>数据报表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card">

      <!-- 报表 -->
      <div style="width:100%;height:500px" ref="chart"></div>

    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      option: {
        title: {
          text: '用户统计'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        legend: {},
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          { boundaryGap: false }
        ],
        yAxis: [
          { axisLine: { show: true } }
        ],
        series: []
      }

    }
  },
  //   钩子函数
  mounted() {
    this.getchart()

  },
  //   计算
  computed: {

  },
  //   方法
  methods: {
    async getchart() {
      let res = await this.axios({
        url: '/v1/reports/type/1',
      })
      console.log(res, 'res');
      this.option.legend = res.data.data.legend
      res.data.data.xAxis.forEach(item=>{
        item.boundaryGap =false
      })
      this.option.xAxis = res.data.data.xAxis
      res.data.data.yAxis.forEach(item=>{
        item.axisLine={},
        item.axisLine.show=true
      })
      this.option.yAxis = res.data.data.yAxis
      this.option.series = res.data.data.series
      this.makechart()
    },
    makechart() {
      let mychart = this.echarts.init(this.$refs.chart)
      mychart.setOption(this.option)
    }
  },
  //    监听
  watch: {},
  //    筛选
  filters: {},
}
</script>
<style  scoped>
.box-card {
  width: 100%;
  margin-top: 15px;
}
</style>